Aim (aim):
A visual representation of numbers of civilization in each continent and different period of times
Visual Design Type (vistype):
Interval selection scatter plot and bar chart
Visual Mappings (vismapping):
X axis: minimum date
Y axis: maximum date
color: Depending on the continent
size of circles: existence period
Data Preparation (dataprep):
For existence period I have subtracted maxDate and minDate.
Using the coordinates provided I have tried to represent each raw with it's continent using a formula created in Excel file.
Improvements (improvements):
As some civilizations in different continents lived in the same period of time you can't visualise on the scatter plot, but you can see them on the bar chart.
import altair as alt
import pandas as pd
from vega_datasets import data
data = pd.read_csv('prehistory-modern.csv')
scale = alt.Scale(domain=['EUROPE','ASIA','AFRICA','OTHER CONTINENT'],
range=['#0AC734', '#0AB1E0', '#EBB10D',"#DC0EF0"])
color = alt.Color('Continent:N', scale=scale)
brush = alt.selection_interval(encodings=['x'])
click = alt.selection_multi(encodings=['color'])
alt.data_transformers.disable_max_rows()
points = alt.Chart().mark_point().encode(
alt.X('minDate', axis = alt.Axis(title = "Starting year of each civilization"),
),
alt.Y('maxDate',axis = alt.Axis(title = "Ending year of each civilization"),
),
color=alt.condition(brush, color, alt.value('lightgray')),
size=alt.Size('Existence period:Q', scale=alt.Scale(range=[0, 200]))
).properties(
).add_selection(
brush
).transform_filter(
click
)
bars = alt.Chart().mark_bar().encode(
x='count()',
y='Continent:N',
color=alt.condition(click, color, alt.value('lightgray')),
).transform_filter(
brush
).properties(
).add_selection(
click
)
alt.vconcat(
points,
bars,
data=data,
title="Number of civilizations in prehistory,middle ages and early modern"
)